﻿<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>整车销售返结算</title>
<script type="text/javascript" src="../js/common.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/shop.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<script type="text/javascript" src="../js/shopSelecterNew.js"></script>
<script type="text/javascript" src="../js/find.js"></script>
<script type="text/javascript" src="../js/pagination.js"></script>
<script type="text/javascript" src="../js/doubleDate2.0.js"></script> 
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<style type="text/css">
.moreData{width:100%;overflow-x:scroll;}
.member_list th{white-space:nowrap;}
</style>
<script type="text/javascript">
$(function(){
	$("#shopIsChoosed").click(function(){
		if($("#shopIsChoosed").is(":checked")){
			$("#shopName").attr("disabled",false);
			
		}else{
			$("#shopName").attr("disabled",true);
		}
	});
	$('#dtBegin').val(getToday());
	 $('#dtEnd').val(getToday());
	 refreshInput($(".serWrapper"));
		$('.doubledate').kuiDate({
			className:'doubledate',
			isDisabled: "0"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
		});
})

var pageIndex = 1
function search(index){
	if(IsNotEmpty(index)){
	pageIndex = index	
	}else{
		pageIndex = 1;
	}
	var mp=$("#mp").val().replace(/\s/gi,'');	
	var dtBegin=$("#dtBegin").val();
	var dtEnd=$("#dtEnd").val();
	var custName=$("#custName").val();
	var shopId="";
	if($("#shopIsChoosed").is(":checked")){		
		shopId=$("#shopName").val();
		if(IsEmpty(shopId)){
			shopId = "";
		}
	}
	
	var params = {'mp':mp,'dtBegin':dtBegin,'dtEnd':dtEnd,'custName':custName,'shopId':shopId}
	
	var dt = _findInfo("../newCarSale/find/allRecord/"+(pageIndex-1)+"/10", params)
	if(IsNotEmpty(dt)&&dt.state==0){
/* 		var p = new Array(cl","ls","FactAmt","FreeAmt","BankAmt","CashAmt","CashCouponAmt","DepositAmt","DepositAmt","VoucherAmt","VoucherMemo","VoucherAmt2","VoucherMemo2","FreeAmt");
		_loadInfo(dt, "memberList", p); */
		$("#memberList tbody").empty()
		$("#sup").html("共"+dt.result.len+"条")
		for(var i=0;i<dt.result.data.length;i++){
			var status = _getIntOfJson(i, dt, "status");
			if(status ==4){
				
			var htm="<tr style=\"white-space: nowrap;color:red;\">"
			}else{
				
			var htm="<tr style=\"white-space: nowrap;\">"
			}

			htm+="<td>"+_getSomeOfJson(i, dt, "billNo")+"</td>"
			htm+="<td>"+_getSomeOfJson(i, dt, "saleType")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "createdTime")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "customerName")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "mp")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "CarSystemName")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "CarTypeName")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "VIN")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "price")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "tax")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "insurance")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "decoration")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "checkCar")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "Outbound")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "serviceAmt")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "postAmt")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "otherAmt")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "factAmt")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "deposit")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "post")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "cash")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "checkAmt")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "Replacement")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "Transfer")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "Staging")+"</td>"
				htm+="<td>"+_getSomeOfJson(i, dt, "credit")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "factAmt")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "memo")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "createdMan")+"</td>"
				htm+="<td>"+_getIntOfJson(i, dt, "saleMan")+"</td>"
				htm+="<td><input class=\" common_btn\" type=\"button\" onclick=\"toPrint("+_getIntOfJson(i, dt, "id")+")\" value=\"返结算\"></td>"

				htm+="</tr>"
				$("#memberList tbody").append(htm)
		}
		
		_loadPage("pager", pageIndex, 10, dt, search, "NoResult")
	}
	var dt2 = _findInfo("../newCarSale/find/allRecordSum", params)
	if(IsNotEmpty(dt2)&&dt2.state==0){
		var factAmt = _getIntOfJson(0, dt2, "factamt");
		var price = _getIntOfJson(0, dt2, "price");
		var tax = _getIntOfJson(0, dt2, "tax");
		var insurance = _getIntOfJson(0, dt2, "insurance");
		var decoration = _getIntOfJson(0, dt2, "decoration");
		var checkCar = _getIntOfJson(0, dt2, "checkCar");
		var Outbound = _getIntOfJson(0, dt2, "Outbound");
		var serviceAmt = _getIntOfJson(0, dt2, "serviceAmt");
		var otherAmt = _getIntOfJson(0, dt2, "otherAmt");
		
		var deposit = _getIntOfJson(0, dt2, "deposit");
		var post = _getIntOfJson(0, dt2, "post");
		var cash = _getIntOfJson(0, dt2, "cash");
		var Transfer = _getIntOfJson(0, dt2, "Transfer");
		var Replacement = _getIntOfJson(0, dt2, "Replacement");
		var Staging = _getIntOfJson(0, dt2, "Staging");
		var credit = _getIntOfJson(0, dt2, "credit");
		var checkAmt = _getIntOfJson(0, dt2, "checkAmt");
		var htm="销售总计："+factAmt+"&nbsp;"+"其中："+"车价合计："+price+"&nbsp;购置税合计："+tax+"&nbsp;保险费合计："+insurance+"&nbsp;装饰合计："+decoration+"&nbsp;验车合计："+checkCar+"&nbsp;出库合计："+Outbound+"&nbsp;金融服务费合计："+serviceAmt+"&nbsp;其它合计："+otherAmt
			htm+="<br>应收总计:"+factAmt+"&nbsp;"+"其中：抵定金总计："+deposit+"&nbsp;刷卡总计："+post+"&nbsp;现金总计："+cash+"&nbsp;支票总计："+checkAmt+"&nbsp;转账总计："+Transfer+"&nbsp;置换款总计计："+Replacement+"&nbsp;分期总计："+Staging+"&nbsp;挂账总计："+credit
			
		$("#sum").html(htm)
	}

	
}

function toPrint(id){

	art.dialog({fixed:true, lock: true,content:"确认要返结算该条数据？",icon:'question',ok: function(){ salebace(id)},cancel:true});

	
}
function salebace(id){
	var dt=_PostInfoRstNoMessage("../newCarSale/saleBack", {'id':id})
	if(dt.state==0){
		search(pageIndex)
		artSuccess("返结算成功")
	}
}

function toAdd(){
	var mp=$("#mp").val().replace(/\s/gi,'');	
	var dtBegin=$("#dtBegin").val();
	var dtEnd=$("#dtEnd").val();
	var custName=$("#custName").val();
	var shopId="";
	if($("#shopIsChoosed").is(":checked")){		
		shopId=$("#shopName").val();
		if(IsEmpty(shopId)){
			shopId = "";
		}
	}
	
	var params = {'mp':mp,'dtBegin':dtBegin,'dtEnd':dtEnd,'custName':custName,'shopId':shopId,'downType':22}
	window.location.href="../csvdown/down/csv/down?"+$.param(params)
}
</script>
</head>

<body>
<div class="container" id="container">
  <div class="container_R fr">
	<div class="place">整车销售返结算</div>
	<div class="member_search">
      <p><span>
        <input type="checkbox" id="shopIsChoosed" style="width:auto;height:auto;border:none;">
        店面：</span>
        <select disabled="disabled" id="shopName" onclick="openShopListPanel(this)" style=";height:20px;">
        </select>
        <span>起始日期：</span>
        <input type="text" readonly class="doubledate ipticon"  id="dtBegin"/>
        <span>截止时间：</span>
        <input type="text" readonly class="doubledate ipticon" id="dtEnd"/>
      </p>
      <p>
      <span>姓名：</span>
        <input type="text" id="custName" class="absoluteTxt">
      <span>手机号：</span>
              <input type="text" id="mp" class="absoluteTxt">
            <input type="button" value="查询" class="btn" onclick="search(1)">
      
      </p>
    </div>
	
    <div class="moreData">
    <table class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList" style="margin-top:45px;position:relative;">
    	<caption class="fixedTit"><strong>收款清单列表        <span id="sup">共0条</span></strong><input type="button" value="导出" class="common_btn addList" onclick="toAdd()"></caption>
    	<thead>
    	<tr style="white-space: nowrap;">
        	<th>单号</th>
        	<th>交款类型</th>
        	<th>时间</th>
        	<th>客户姓名</th>
        	<th>电话</th>
        	<th>车系</th>
        	<th>车型</th>
        	<th>VIN</th>
        	<th>车价</th>
        	<th>购置税</th>
        	<th>保险费</th>
        	<th>装饰</th>
        	<th>验车</th>
        	<th>出库</th>
        	<th>金融服务费</th>
        	<th>刷卡手续费</th>
        	<th>其它</th>
        	<th>合计</th>
        	<th>抵定金</th>
        	<th>刷卡</th>
        	<th>现金</th>
        	<th>支票</th>
        	<th>置换款</th>
        	<th>转账</th>
        	<th>分期</th>
        	<th>挂账</th>
        	<th>合计</th>
        	<th>备注</th>
        	<th>收银员</th>
        	<th>销售顾问</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody></tbody>
    </table>
    </div>
     <div id="sum" style="float: left;"></div>
    <div id="NoResult"  class="Nothing" style="text-align:center;display: none;">无符合条件的数据！</div>
    <div id="pager" style="float: right;"></div>
  </div>
  <div class="fc"></div>
</div>
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
$(".moreData").scroll(function(){
	if($(this).scrollLeft()+$(this).width()>=$(this).find("table").width())return;
	$(this).find(".fixedTit").css("left",$(this).scrollLeft())	
})
addMargin($(".hideDiv"))
clearThis("absoluteTxt");
</script>
</body>
</html>
